package vars

import (
	"fmt"
	"gitee.com/csingo/cHelper"
	"gitee.com/csingo/cServer"
	"path/filepath"
)

var RouteConfig = &cServer.RouteConf{
	Middlewares: &cServer.RouteConf_Middlewares{
		Prefix: []*cServer.RouteConf_Middleware{
			{App: "demo", Name: "HelloMiddleware"},
		},
		Surfix: []*cServer.RouteConf_Middleware{},
	},
	Routes: []*cServer.RouteConf{
		// 默认路由
		{Path: "/rpc/call", Method: []string{"POST"}, App: "csingo", Controller: "RpcController", Function: "Handler"},
		{Path: "/ping", Method: []string{"GET"}, App: "demo", Controller: "HelloController", Function: "Ping"},
		{Path: "/hello", Method: []string{"GET"}, App: "demo", Controller: "HelloController", Function: "Say"},
		{Path: "/error", Method: []string{"GET"}, App: "demo", Controller: "HelloController", Function: "Error"},
		{Path: "/config", Method: []string{"GET"}, App: "demo", Controller: "HelloController", Function: "Config"},
		// 静态文件路由
		{Path: "/packages.json", File: filepath.Clean(fmt.Sprintf("%s/packages.json", cHelper.EnvToString("SATIS_PACKAGES_PATH", "D:\\project\\self\\satis-go\\resource\\packages")))},
		{Path: "/dist", Dir: filepath.Clean(fmt.Sprintf("%s/dist", cHelper.EnvToString("SATIS_PACKAGES_PATH", "D:\\project\\self\\satis-go\\resource\\packages")))},
		{Path: "/include", Dir: filepath.Clean(fmt.Sprintf("%s/include", cHelper.EnvToString("SATIS_PACKAGES_PATH", "D:\\project\\self\\satis-go\\resource\\packages")))},
		{Path: "/p2", Dir: filepath.Clean(fmt.Sprintf("%s/p2", cHelper.EnvToString("SATIS_PACKAGES_PATH", "D:\\project\\self\\satis-go\\resource\\packages")))},
		// 编译文件路由
		{Path: "/js", View: "js"},
		{Path: "/css", View: "css"},
		{Path: "/fonts", View: "fonts"},
		{Path: "/", Method: []string{"GET"}, App: "collector", Controller: "HtmlController", Function: "Index"},
		{Path: "/index.html", Method: []string{"GET"}, App: "collector", Controller: "HtmlController", Function: "Index"},
		// API路由
		{Path: "/collector/test", Method: []string{"POST"}, App: "collector", Controller: "PackagistController", Function: "Test"},
		{Path: "/collector/common/project-name", Method: []string{"POST"}, App: "collector", Controller: "CommonController", Function: "ProjectName"},
		{Path: "/collector/packages", Routes: []*cServer.RouteConf{
			{Path: "/add", Method: []string{"POST"}, App: "collector", Controller: "PackagesController", Function: "Add"},
			{Path: "/del", Method: []string{"POST"}, App: "collector", Controller: "PackagesController", Function: "Del"},
			{Path: "/all-by-include", Method: []string{"POST"}, App: "collector", Controller: "PackagesController", Function: "AllByInclude"},
		}},
		{Path: "/collector/includes", Routes: []*cServer.RouteConf{
			{Path: "/add", Method: []string{"POST"}, App: "collector", Controller: "IncludesController", Function: "Add"},
			{Path: "/del", Method: []string{"POST"}, App: "collector", Controller: "IncludesController", Function: "Del"},
			{Path: "/all", Method: []string{"POST"}, App: "collector", Controller: "IncludesController", Function: "All"},
		}},
	},
}
